package com.ht.medicaltreatment.viewmodel

import androidx.lifecycle.viewModelScope
import com.ht.medicaltreatment.bean.CentrifugeOrderDetailBean
import com.ht.medicaltreatment.bean.CentrifugeOrderOverTimeDetailBean
import com.xgst.lib.http.ApiResult
import kotlinx.coroutines.launch

class CentrifugeOrderDetailViewModel : BaseViewModel() {
    fun getData(centrifugeOrderId : String,onSuccess:(MutableList<CentrifugeOrderDetailBean>)->Unit,onError:(String)->Unit){
        viewModelScope.launch {
            val bean = mApi.getData(centrifugeOrderId)
            when(bean){
                is ApiResult.Success -> {
                    onSuccess(bean.data.data!!)
                }
                is ApiResult.Error -> onError(bean.errorMessage)
            }
        }
    }

    fun overTimeSample(projectId:String, value:String, onSuccess:(MutableList<CentrifugeOrderOverTimeDetailBean>?)->Unit, onError: (String) -> Unit){
        viewModelScope.launch {
            val bean = mApi.overTimeSample(projectId,value)
            when(bean){
                is ApiResult.Success -> {
                    onSuccess(bean.data.data)
                }
                is ApiResult.Error -> onError(bean.errorMessage)
            }
        }
    }
}
